#ifndef __Dadi__JORDANINCLUSION__
#define __Dadi__JORDANINCLUSION__

#include<iostream>
#include<valarray>

#define TEMPLATE template <typename T>

TEMPLATE class Inclusion;

TEMPLATE
class Inclusion
{
private:
    std::valarray<T> curve1x;
    std::valarray<T> curve1y;
    std::valarray<T> curve2x;
    std::valarray<T> curve2y;
    T c1xmin, c1xmax, c1ymin, c1ymax, c2xmin, c2xmax, c2ymin, c2ymax;
public:
    Inclusion();
    Inclusion(std::valarray<T> c1x, std::valarray<T> c1y, std::valarray<T> c2x, std::valarray<T> c2y);
    void resetcurve(std::valarray<T> c1x, std::valarray<T> c1y, std::valarray<T> c2x, std::valarray<T> c2y);
    void inclusion();
};

TEMPLATE
Inclusion<T>::Inclusion()
{
};

TEMPLATE
Inclusion<T>::Inclusion(std::valarray<T> c1x, std::valarray<T> c1y, std::valarray<T> c2x, std::valarray<T> c2y)
{
    curve1x = c1x;
    curve1y = c1y;
    curve2x = c2x;
    curve2y = c2y;
};

TEMPLATE
void Inclusion<T>::resetcurve(std::valarray<T> c1x, std::valarray<T> c1y, std::valarray<T> c2x, std::valarray<T> c2y)
{
    curve1x = c1x;
    curve1y = c1y;
    curve2x = c2x;
    curve2y = c2y;
};

TEMPLATE
void Inclusion<T>::inclusion()
{
    c1xmin = curve1x.min();
    c1xmax = curve1x.max();
    c1ymin = curve1y.min();
    c1ymax = curve1y.max();
    c2xmin = curve2x.min();
    c2xmax = curve2x.max();
    c2ymin = curve2y.min();
    c2ymax = curve2y.max();
    if(c1xmin == c2xmin && c1xmax == c2xmax && c1ymin == c2ymin && c1ymax == c2ymax)
	std::cout << "Fail to know the inclusion between the two curve." << std::endl;
    else if(c1xmin >= c2xmin && c1xmax <= c2xmax && c1ymin >= c2ymin && c1ymax <= c2ymax)
	std::cout << "The second curve includes the first curve." << std::endl;
    else if(c1xmin <= c2xmin && c1xmax >= c2xmax && c1ymin <= c2ymin && c1ymax >= c2ymax)
	std::cout << "The first curve includes the second curve." << std::endl;
    else
	std::cout << "The two curves are not almost disjoint." << std::endl;
};


#else
//Do nothing.
#endif
